#pragma once
#include <iostream>
#include <ostream>
#include <assert.h>

using std::cout;
using std::cin;
using std::endl;
using std::ostream;
using std::istream;

//类中短小、适合做内联的函数，直接在类内部定义
class Date
{
	friend ostream& operator << (ostream& out, const Date& d);
	friend istream& operator >> (istream& in,  Date& d);

public:
	// 初始化
	Date(int year = 2000, int month = 1, int day = 1)
	{
		_year = year;
		_month = month;
		_day = day;
	}

	//显示日期时间内容："年/月/日."
	void Print()
	{
		cout << _year << "/" << _month << "/" << _day << "." << endl;
	}

	Date& operator += (int day);

	Date operator + (int day) const;

	Date& operator -= (int day);

	Date operator - (int day) const;

	int operator  - (const Date& d) const;// day = Date - Date

	Date& operator ++ ();   // 前置++

	Date operator ++ (int); // 后置++ -参数列表里的int没有实际用途仅仅是为了占位，主要是区别于前置++函数，构成函数重载

	Date& operator -- ();   // 前置--

	Date operator -- (int); // 后置--

	bool operator == (const Date& d) const;

	bool operator != (const Date& d) const;

	bool operator < (const Date& d) const;

	bool operator <= (const Date& d) const;

	bool operator > (const Date& d) const;

	bool operator >= (const Date& d) const;

private:
	int _year;
	int _month;
	int _day;
};

// 把两个作为自定义类型输入输出的运算符重载函数作为内联函数，目的是是调用时效率更高
inline ostream& operator << (ostream& out, const Date& d)
{
	out << d._year << "/" << d._month << "/" << d._day << "." << endl;
	return out;
}

inline istream& operator >> (istream& in, Date& d)
{
	in >> d._year >> d._month >> d._day;
	return in;
}
